home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Tricks of the Mac Game Programming Gurus
/
TricksOfTheMacGameProgrammingGurus.iso
/
More Source
/
C⁄C++
/
AIFF DSP v22
/
plugin_src
/
num_input_macros.h
< prev
next >
Wrap
Text File
|
1995-01-30
|
592b
|
18 lines
/* macros useful for numerical input */
#define GET_NUM_P( prompt, scanfmt, x ) \
fprintf( stderr, prompt " (must be positive): " ); \
GET_NUM_COND( scanfmt, x, (x) > 0 )
#define GET_NUM_RANGE( prompt, printfmt, scanfmt, x, min, max ) \
fprintf( stderr, prompt " [" printfmt "..." printfmt "]: ", min, max ); \
GET_NUM_COND( scanfmt, x, (x) >= (min) && (x) <= (max) )
#define GET_NUM_COND( scanfmt, x, cond ) \
while ( !( scanf( scanfmt, &(x) ) && (cond) ) ) \
{ \
getchar(); \
fprintf( stderr, "Try again (last input was illegal): " ); \
} \
getchar()